-
Notifications
You must be signed in to change notification settings - Fork 12
Detect dead enum cases #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Just my 2 cents: I'm not sure this is a good idea. I once made a PHPStan rule to detect them. And most of the time, our enums are mapped to database state. Not every case is tested. So it will produce lots of errors. I couldn't find anything worth deleting. |
@ruudk Thx, I can imagine such problems, but you can always disable the analysis: ignoreErrors:
- identifier: shipmonk.deadEnumCase And some codebases may benefit from this. Also, those mapped to database can be easily detected in custom usage provider (assuming Doctrine): #[Column(type: Types::STRING, enumType: InvoiceStatus::class]
private InvoiceStatus $status; |
I just realized that we should indeed create a usage detector, great 😁 |
I just had an idea, whenever Together with the fact that it's used inside |
Both those are already implemented. The only issue with this being enabled by default are typically API input objects, where enums are typically deserialized into the objects. Those cannot be easily natively supported and each app need to add own provider. Basically, this PR is done and working (I even fully used it in our huge codebase), but I'm still thinking it might be disabled by default. |
No description provided.